
package com.dps.omc.service.impl;
import com.dps.omc.model.Job;
import com.dps.omc.model.User;
import com.dps.common.utils.IdGenerator;
import com.dps.omc.service.IJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dps.common.service.impl.AbstractPageService;
import com.dps.omc.dao.IJobLogDAO;
import com.dps.omc.model.JobLog;

@SuppressWarnings("unchecked")
@Service("JobLogServiceImpl")

public class JobLogServiceImpl extends AbstractPageService<IJobLogDAO,JobLog> implements IJobLogService {

	@Autowired
	private IJobLogDAO jobLogDAO;
	@Override
	public boolean getEnableDataPerm() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public IJobLogDAO getDao() {
		return jobLogDAO;
	}

	@Override
	public void createLog(Job job,User lastModified) {
		JobLog jobLog = new JobLog();
		jobLog.setId(IdGenerator.createNewId());
		jobLog.setJobId(job.getId());
		jobLog.setName(job.getName());
		jobLog.setGroupType(job.getGroupType());
		jobLog.setSubjectId(job.getSubjectId());
		jobLog.setArtifactId(job.getArtifactId());
		jobLog.setArtifactPath(job.getArtifactPath());
  		jobLog.setTemplateId(job.getTemplateId());
		jobLog.setNote(job.getNote());
		jobLog.setIsuploadfile(job.getIsuploadfile());
		jobLog.setIscron(job.getIscron());
		jobLog.setCronexpr(job.getCronexpr());
		jobLog.setCreaterId(job.getCreaterId());
		jobLog.setCreaterName(job.getCreaterName());
		jobLog.setCreateDate(job.getCreateDate());
		jobLog.setStatus(job.getStatus());
		jobLog.setAuditState(job.getAuditState());
//		jobLog.setLastModifiedTime(job.getLastModifiedTime());
		jobLog.setLastModifiedId(lastModified.getId());
		jobLog.setLastModifiedName(lastModified.getRealName());
		jobLog.setTaskSucc(job.getTaskSucc());
		jobLog.setTaskFail(job.getTaskFail());
		this.add(jobLog);
	}
}
